package com.wn.ticket.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.ticket.common.PageBean;
import com.wn.ticket.common.Utils;
import com.wn.ticket.entity.Perform;
import com.wn.ticket.entity.User;
import com.wn.ticket.mapper.AdminMapper;
import com.wn.ticket.mapper.UserMapper;
import com.wn.ticket.service.UserService;
import com.wn.ticket.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(User user) {
        return userMapper.userLogin(user);
    }

    @Override
    public void add(User user) {
        userMapper.userInsert(user);
    }

    @Override
    public void update(User user) {
        userMapper.userUpdate(user);
    }

    @Override
    public List<User> getAll() {
        return userMapper.userList();
    }

    @Override
    public PageBean<User> getPage(User user,int currPage,int pageSize) {
        Page<User> page = PageHelper.startPage(currPage, pageSize);
        List<User> list = userMapper.getByCondition(user);
        PageBean<User> pageBean = Utils.getPageBean(User.class, page, list, currPage, pageSize);
        return pageBean;
    }

    @Override
    public int getCount() {
        return userMapper.getCount();
    }

    @Override
    public List<User> getByRegistTime(String startTime) {
        return userMapper.getByRegistTime(startTime);
    }

    @Override
    public User getById(int id) {
        return userMapper.getById(id);
    }


}
